package com.egao.texasHoldEmPoker.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.*;
import com.egao.common.core.annotation.OperLog;
import com.egao.texasHoldEmPoker.entity.PlayerJeton;
import com.egao.texasHoldEmPoker.service.PlayerJetonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.apache.poi.ss.formula.functions.T;


/**
 *
 * 下注
 * @author : Doman
 * @date : 2022-01-26 12:21:48
 * @version ：1.0
 */

@Api(tags = "下注")
@RestController
@RequestMapping("/api/texasHoldEmPoker/playerJeton")
public class PlayerJetonController extends BaseController {

	@Autowired
	private PlayerJetonService playerJetonService;

	/**
	 * 分页查询列表
	 */
//	@PreAuthorize("hasAuthority('texasHoldEmPoker:playerJeton:list')")
    //@OperLog(value = "下注", desc = "分页查询")
    @ApiOperation(value ="分页查询下注",notes = "" +
        "limit:每页显示几行 必填\n" +
        "page:第几页 必填\n" +
        " \n\n\n" +
        "返回的结果:\n" +
        "id:id\n" +
        "playerId:play id\n" +
        "price:金额\n" +
        "remark:备注\n" +
        "orderNum:排序\n" +
        "createTime:创建时间\n" +
        "createUser:创建人\n" +
        "updateTime:更新时间\n" +
        "updateUser:更新人\n" +
        "",httpMethod = "GET")
    @ApiPageParam
    @GetMapping("/page")
    public JsonResult page(PageResult2<T> page, PlayerJeton playerJeton) throws Exception{
        return playerJetonService.list(page, playerJeton, getLoginUser());
    }

    /**
     * 查询全部下注
     */
//    @PreAuthorize("hasAuthority('texasHoldEmPoker:playerJeton:list')")
    //@OperLog(value = "下注", desc = "查询全部")
    @ApiOperation("查询全部下注")
    @GetMapping()
    public JsonResult list(PlayerJeton playerJeton){
        return playerJetonService.list(playerJeton, getLoginUser());
    }

    /**
     * 根据id查询下注
     */
//    @PreAuthorize("hasAuthority('texasHoldEmPoker:playerJeton:list')")
    //@OperLog(value = "下注", desc = "根据id查询")
    @ApiOperation("根据id查询下注")
    @GetMapping("/get")
    public JsonResult get(PlayerJeton playerJeton) {
        return playerJetonService.getById(playerJeton);
		// 使用关联查询
        //PageParam<playerJeton> pageParam = new PageParam<>();
		//pageParam.put("id", id);
        //List<playerJeton> records = playerJetonService.listAll(pageParam.getNoPageParam());
        //return JsonResult.ok().setData(pageParam.getOne(records));
    }


    /**
     * 添加下注
     */
//    @PreAuthorize("hasAuthority('texasHoldEmPoker:playerJeton:save')")
    @OperLog(value = "下注", desc = "添加", param = false, result = true)
    @ApiOperation(value ="添加下注",notes = "" +
            "playerId:play id\n" +
            "price:金额\n" +
            "remark:备注\n" +
            "orderNum:排序\n" +
        "",httpMethod = "POST")
    @PostMapping()
    public JsonResult save(PlayerJeton playerJeton) {
        return playerJetonService.save(playerJeton, getLoginUser());
    }

    /**
     * 修改下注
     */
//    @PreAuthorize("hasAuthority('texasHoldEmPoker:playerJeton:update')")
    @OperLog(value = "下注", desc = "修改", param = false, result = true)
    @ApiOperation(value ="修改下注",notes = "" +
            "id:id\n" +
            "playerId:play id\n" +
            "price:金额\n" +
            "remark:备注\n" +
            "orderNum:排序\n" +
        "",httpMethod = "PUT")
    @PutMapping()
    public JsonResult update(PlayerJeton playerJeton) {
        return playerJetonService.update(playerJeton, getLoginUser());
    }

    /**
     * 删除下注
     */
//    @PreAuthorize("hasAuthority('texasHoldEmPoker:playerJeton:remove')")
    @OperLog(value = "下注", desc = "删除", result = true)
    @ApiOperation(value ="删除下注",notes = "" +
      "id:id\n" +
      "",httpMethod = "POST")
    @DeleteMapping("/remove")
    public JsonResult remove(PlayerJeton playerJeton ) {
        return playerJetonService.remove(playerJeton, getLoginUser());
    }

    /**
     * 批量添加下注
     */
    /**@RequiresPermissions("texasHoldEmPoker:playerJeton:save")
    @OperLog(value = "下注", desc = "批量添加", param = false, result = true)
    @ResponseBody
    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<PlayerJeton> list) {
        if (playerJetonService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改下注
     */
    /**@RequiresPermissions("texasHoldEmPoker:playerJeton:update")
    @OperLog(value = "下注", desc = "批量修改", result = true)
    @ResponseBody
    @PutMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<PlayerJeton> batchParam) {
        if (batchParam.update(playerJetonService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除下注
     */
    /**@RequiresPermissions("texasHoldEmPoker:playerJeton:remove")
    @OperLog(value = "下注", desc = "批量删除", result = true)
    @ResponseBody
    @DeleteMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (playerJetonService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
